home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / c / stdlib / RCS / atexit.c,v < prev    next >
Encoding:
Text File  |  1992-03-27  |  3.9 KB  |  182 lines

  1. head     1.5;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.5
  10. date     92.03.27.13.41.19;  author rab;  state Exp;
  11. branches ;
  12. next     1.4;
  13.  
  14. 1.4
  15. date     89.03.22.00.46.53;  author rab;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.07.25.14.15.30;  author ouster;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.07.14.09.46.19;  author ouster;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.05.21.14.46.05;  author ouster;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 1.5
  40. log
  41. @Added on_exit, and had to change atexit.c and exit.c to make local variables global.
  42. @
  43. text
  44. @/* 
  45.  * atexit.c --
  46.  *
  47.  *    This file contains the source code for the "atexit" library
  48.  *    procedure.
  49.  *
  50.  * Copyright 1988 Regents of the University of California
  51.  * Permission to use, copy, modify, and distribute this
  52.  * software and its documentation for any purpose and without
  53.  * fee is hereby granted, provided that the above copyright
  54.  * notice appear in all copies.  The University of California
  55.  * makes no representations about the suitability of this
  56.  * software for any purpose.  It is provided "as is" without
  57.  * express or implied warranty.
  58.  */
  59.  
  60. #ifndef lint
  61. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/atexit.c,v 1.4 89/03/22 00:46:53 rab Exp Locker: rab $ SPRITE (Berkeley)";
  62. #endif /* not lint */
  63.  
  64. #include <stdlib.h>
  65.  
  66. /*
  67.  * Variables shared with exit.c:
  68.  */
  69.  
  70. extern void (*_exitHandlers[])();    /* Function table. */
  71. extern int _exitNumHandlers;        /* Number of functions currently
  72.                      * registered in table. */
  73. extern long _exitHandlerArgs[];        /* Arguments to pass to functions. */
  74. extern int _exitTableSize;        /* Number of entries in table. */
  75.  
  76. /*
  77.  *----------------------------------------------------------------------
  78.  *
  79.  * atexit --
  80.  *
  81.  *    Register a function ("func") to be called as part of process
  82.  *    exiting.
  83.  *
  84.  * Results:
  85.  *    The return value is 0 if the registration was successful,
  86.  *    and -1 if registration failed because the table was full.
  87.  *
  88.  * Side effects:
  89.  *    Information will be remembered so that when the process exits
  90.  *    (by calling the "exit" procedure), func will be called.  Func
  91.  *    takes no arguments and returns no result.  If the process
  92.  *    terminates in some way other than by calling exit, then func
  93.  *    will not be invoked.
  94.  *
  95.  *----------------------------------------------------------------------
  96.  */
  97.  
  98. int
  99. atexit(func)
  100.     void (*func)();            /* Function to call during exit. */
  101. {
  102.     if (_exitNumHandlers >= _exitTableSize) {
  103.     return -1;
  104.     }
  105.     _exitHandlers[_exitNumHandlers] = func;
  106.     _exitHandlerArgs[_exitNumHandlers] = 0;
  107.     _exitNumHandlers += 1;
  108.     return 0;
  109. }
  110. @
  111.  
  112.  
  113. 1.4
  114. log
  115. @*** empty log message ***
  116. @
  117. text
  118. @d18 1
  119. a18 1
  120. static char rcsid[] = "$Header: /sprite/src/lib/c/stdlib/RCS/atexit.c,v 1.3 88/07/25 14:15:30 ouster Exp Locker: rab $ SPRITE (Berkeley)";
  121. d27 2
  122. a28 2
  123. void (*_exitHandlers[32])();        /* Function table. */
  124. int _exitNumHandlers = 0;        /* Number of functions currently
  125. d30 2
  126. a31 1
  127. int _exitTableSize = 32;        /* Number of entries in table. */
  128. d63 1
  129. @
  130.  
  131.  
  132. 1.3
  133. log
  134. @Wasn't returning values correctly.
  135. @
  136. text
  137. @d18 4
  138. a21 2
  139. static char rcsid[] = "$Header: atexit.c,v 1.2 88/07/14 09:46:19 ouster Exp $ SPRITE (Berkeley)";
  140. #endif not lint
  141. @
  142.  
  143.  
  144. 1.2
  145. log
  146. @Move variables from exit.c to atexit.c, so that atexit can be
  147. used along with a private exit (as in csh).
  148. @
  149. text
  150. @d18 1
  151. a18 1
  152. static char rcsid[] = "$Header: atexit.c,v 1.1 88/05/21 14:46:05 ouster Exp $ SPRITE (Berkeley)";
  153. d40 1
  154. a40 1
  155.  *    and 1 if registration failed because the table was full.
  156. d57 1
  157. a57 1
  158.     return 1;
  159. d61 1
  160. @
  161.  
  162.  
  163. 1.1
  164. log
  165. @Initial revision
  166. @
  167. text
  168. @d18 1
  169. a18 1
  170. static char rcsid[] = "$Header: proto.c,v 1.2 88/03/11 08:39:08 ouster Exp $ SPRITE (Berkeley)";
  171. d22 1
  172. a22 1
  173.  * Variables shared from exit.c:
  174. d25 2
  175. a26 2
  176. extern void (*_exitHandlers[])();    /* Function table. */
  177. extern int _exitNumHandlers;        /* Number of functions currently
  178. d28 1
  179. a28 1
  180. extern int _exitTableSize;        /* Number of entries in table. */
  181. @
  182.